//
//  GCDAsyncSocketManager.h
//  GCDAsyncSocketManagerDemo
//
//  Created by 于鹏 on 2017/7/13.
//  Copyright © 2017年 于鹏. All rights reserved.
//

#import <Foundation/Foundation.h>

#define TCPSocketManager_instance [GCDAsyncSocketManager shareInstance]

@protocol TCPAsyncSocketDelegate <NSObject>

@optional
/**
 *  监听到服务器发送过来的消息
 */
- (void)tcpSocketReadedData:(NSData *)data;

@end

@interface GCDAsyncSocketManager : NSObject
/**
 *tcp连接状态:1已连接, -1未连接, 0连接中
 */
@property (nonatomic, assign) NSInteger connectStatus;
@property (nonatomic, strong, readonly) NSData *sendBeatData; //心跳包数据


/**
 socket 回调
 */
@property (nonatomic, weak) id<TCPAsyncSocketDelegate> tcpSocketDelegate;

/**
 获取单例
 
 @return 单例对象
 */
+ (GCDAsyncSocketManager *)shareInstance;

/**
 连接 socket

 @param delegate delegate
 */
//- (void)connectSocketWithDelegate:(id)delegate;
- (void)connectSocket;
/**
 socket 连接成功后发送心跳的操作

 @param beatBody 心跳包数据
 */
- (void)socketDidConnectBeginSendBeat:(NSData *)beatBody;

/**
 向服务器发送数据

 @param data data
 */
- (void)socketWriteData:(NSData *)data;

/**
 socket 读取数据
 */
- (void)socketBeginReadData;

/**
 * socket 主动断开连接
 */
- (void)disconnectSocket;

/**
 *  设置连接的host和port
 */
- (void)changeHost:(NSString *)host port:(NSInteger)port;

@end
